package com.xms.file.service;

import com.xms.utils.FileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 附件模块初始化
 * </p>
 *
 * @author migo
 * @since 2021/11/8
 */
@Component
public class AttachmentModuleInit implements ApplicationListener<ContextRefreshedEvent> {
    private static final Logger LOGGER = LoggerFactory.getLogger(AttachmentModuleInit.class);
    private IAttachmentSettings _attachmentSettings;

    @Autowired
    public AttachmentModuleInit(IAttachmentSettings attachmentSettings){
        _attachmentSettings = attachmentSettings;
    }

    @Override
    public void onApplicationEvent(ContextRefreshedEvent event) {
        LOGGER.info("附件模块初始化");
        FileUtil.mkdirIfNotExists(_attachmentSettings.getRootPath());
    }
}
